<?php

namespace app\saas\controller;

use app\saas\service\ManagerService;

/** 后台管理员管理 */
class ManagerController extends BaseController
{
    // 账户列表
    public function getAccountList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(ManagerService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->getAccountList();
        return $this->return_result($this->returnData);
    }

    // 管理员基本信息
    public function getInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(ManagerService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->getInfo();
        return $this->return_result($this->returnData);
    }

    // 所有管理员
    public function getAll(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(ManagerService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->getAll();
        return $this->return_result($this->returnData);
    }

    // 更新账户信息
    public function doUpdate(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(ManagerService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->update();
        return $this->return_result($this->returnData);
    }

    // 添加账户
    public function doAdd(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(ManagerService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->add();
        return $this->return_result($this->returnData);
    }

    // 修改密码
    public function doModifyPwd(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(ManagerService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->modifyPwd();
        return $this->return_result($this->returnData);
    }

    // 修改手机号
    public function doModifyMobile(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(ManagerService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->modifyMobile();
        return $this->return_result($this->returnData);
    }

    // 删除
    public function doDelete(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(ManagerService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->delete();
        return $this->return_result($this->returnData);
    }
}